import { get, fnChoose, lsGetStr, fnUpload, post } from '../../utils/request.js';
var { getLoginedUser, fnLoading, fnHideLoading, fnSuccess, fnFail } = require('../../utils/index');
var WxParse = require('../wxParse/wxParse.js');
// pages/item/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    verifyPhone:false,
    typeId:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this;
    that.setData({
      typeId: options.id
    })
    fnLoading('加载中');
    wx.setNavigationBarTitle({
      title: options.type == '14224' ? '0元软著申请' :'加急软著申请',
    })
    get({
      path: '/info/detail/' + (options.id || 998),//默认其他业务 
    })
      .then(function (data) {
        fnHideLoading();

        // WxParse.wxParse('detailHtml', 'html', data.content, that, 5);
        that.setData({
          detail: data.content,
          path: options.id ? '/pages/certificate/index?type=14184' : '',
          title: data.summary,
          
        })
      })
      .catch(function () {
        fnHideLoading();
        fnFail('请求错误，请稍后重试~')
      })
  },
  navTo(){
    let that = this;
    get({
      path: "user/getInfo"
    }).then(function (res) {
      // console.log(res)
      if (!res.user.phone) {
        that.setData({
          verifyPhone: true,
        })
      } else {
        wx.navigateTo({
            url: that.data.path,
          })
      }
    })
    // getLoginedUser()
    //   .then(user => {
    //     console.log(user);
    //     if (!user.phone){
    //       that.setData({
    //         verifyPhone:true,
    //         redirectTo: that.data.path
    //       })
    //     }else{
    //       wx.navigateTo({
    //         url: that.data.path,
    //       })
    //     }
    //   })
  }
})